import copy
import re
import qrcode

from PySide6.QtCore import QDateTime, Slot, Qt
from PySide6.QtWidgets import QMessageBox, QDialog, QTableWidgetItem, QMainWindow, QButtonGroup
from PySide6.QtGui import QIcon, QColor, QPixmap

from Devices.Chiot.BsDevs.ComDev.Forms.ComDevWindow import ComDevWindow
from Devices.Chiot.BsDevs.TestPlug.PlugDevice import PlugDevice
from Devices.Chiot.BsDevs.TestPlug.PlugParser import PlugParser
from Components.MessageBoxFunc import MessageBoxFunc

from Devices.Chiot.BsDevs.TestPlug.Forms.PlugWindow_UI import Ui_FormPlugWindow
from Devices.Chiot.BsDevs.TestPlug.Forms.TimerSetWindow import TimerSetWindow

from Funcs.Config import Config


class TestPlugWindow(ComDevWindow):
    # 0、窗体初始化、状态变量初始化
    def __init__(self, supportDevice, parent = None):
        # 注意在实现特有设备时，一定要先将其ui对象加载完毕
        super().__init__(supportDevice, parent)

        self.FullStatus = PlugDevice.PlugFullStatus()
        self.deviceName = supportDevice.deviceDisplayName

        self._ui = Ui_FormPlugWindow()
        self._ui.setupUi(self)
        self.initUiWindow()
        self.SetupUi(self._ui)

        # self.testUi()

     # 1、数据解析
    def setHeartbeatStatus(self):
        pass

    def CmdRptStatusReceived(self, msgValue):
        if PlugParser.ParseRptStatus(msgValue, self.FullStatus):
            self.setFullStatus()

    def CmdHeartbeatReceived(self, msgValue):
        if PlugParser.ParseHeartbeat(msgValue, self.FullStatus):
            self.setFullStatus()
            self.setHeartbeatStatus()

    def CmdFullStatusReceived(self, msgValue):
        pass

    def CmdMsgValueReceived(self, msgName, msgValue):
        pass

    def CmdRptCustomReceived(self, msgValue):
        pass

    # 2、运行状态
    def setFullStatus(self):
        pass

    